DocumentInteraction
The DocumentInteraction interface presents the system "Open in…" menu (and the fuller options menu) for a file, letting the user pick an app to open or copy the file with.
There is no "open in default app" on iOS. iOS has no concept of a default app per file type, and no public API to open a file directly in its associated app. Presenting this menu and letting the user choose is the only supported way to hand a file to another app.
API
Both resolve to the bundle identifier of the app the file was sent to, or null if the user dismissed the menu without choosing an app (for optionsMenu, null also covers performing a non-open action such as Copy).
openInMenurejects if the file does not exist, or if no app is available to open it.optionsMenurejects if the file does not exist.
On iPad the menu is shown as a popover anchored to the center of the current page.
Example
Notes
filePathmust be the absolute path of an existing file.- For files obtained from a document picker (security-scoped), make sure your script holds access to the file before presenting the menu.
- The file's display name comes from its file name; the file type is inferred from its extension.
